<template>
  <div>
    <el-form 
      label-width="100px"
      label-position="top"
      class="enterpriseForm"
      :model="webimSetData"
      ref="webimSetData">
      <h3 class="title">{{$t('configLazyLoad.visitorWaitConfig.enterprisePush')}}</h3>
      <el-form-item :label="$t('config.channel.AgentOfflineTipSet')" prop="tiktokMsg">
        <el-input type="textarea" :rows="3" v-model="webimSetData.tiktokMsg"></el-input>
        <p class="remark">{{$t('configLazyLoad.visitorWaitConfig.wechatRemark1')}}</p>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="primary_btn fr" @click="saveFun">{{$t('public.save')}}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {checkform} from '@/utils/validate'
export default {
  name: 'TikTokWebimSet',
  data () {
    let validateNum = (rule, value, callback) => {
      let message = checkform(value, 'Number3')
      if (message) {
        callback(new Error(this.$t(message)))
      } else {
        callback()
      }
    }
    return {
      webimSetData: {
        tiktokMsg: ''
      }
    }
  },
  methods: {
    saveFun () {
      this.$refs.webimSetData.validate((valid) => {
        if (valid) {
          this.$store.dispatch('saveGlobalSet', this.webimSetData).then((rep) => {
            if (rep.success) {
              this.$message.success(this.$t('config.channel.configSuccess'))
            } else {
              this.$message.error(this.$t('qualityCheck.saveFali'))
            }
          })
        }
      })
    }
  },
  beforeMount () {
    this.$store.dispatch('getGlobalSetById', {}).then((resp) => {
      if (resp.success && resp.row) {
        this.webimSetData._id = resp.row._id
        this.webimSetData.tiktokMsg = resp.row.tiktokMsg || ''
      }
    })
  }
}
</script>
<style lang="stylus" scoped>
  @import "../../../../../assets/common.styl"
    .enterpriseForm
      width 500px
      .title
        font-weight 900
        margin-bottom 5px
      .remark
        color: #888888
        font-size 12px
        margin-top 10px
</style>